package sg.java.concepts.scjp.collections.comparable;

/**
 * Domain class that implements <code>Comparable</code> interface.
 * 
 * @author Oh Chin Boon
 * 
 */
public class Car implements Comparable<Car> {
	private String brand;

	public Car(final String brand) {
		this.brand = brand;
	}

	public String getBrand() {
		return brand;
	}

	public void setBrand(final String brand) {
		this.brand = brand;
	}

	/**
	 * Overrides {@link Comparable#compareTo(Object)}.
	 */
	public int compareTo(final Car o) {
		return this.brand.compareTo(o.brand);
	}

	/**
	 * Overriden for clarity.
	 */
	public String toString() {
		return this.brand;
	}
}
